package com.rtx.edi.platform.express.auth.controller;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rtx.edi.model.express.auth.dto.PlExpressSubscriptionDto;
import com.rtx.edi.model.express.auth.po.PlExpressSubscription;
import com.rtx.edi.model.response.EdiResponse;
import com.rtx.edi.platform.express.auth.service.PlExpressSubscriptionService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = {"授权订购关系"})
@RestController
@RequestMapping("/v1/plExpressSubscription")
public class PlExpressSubscriptionController {
	
	@Autowired
	private PlExpressSubscriptionService plExpressSubscriptionService;
	
	@ApiOperation(value = "授权订购关系列表", notes = "授权订购关系列表")
    @PostMapping("qryPlExpressSubscriptionList")
	public EdiResponse qryPlExpressSubscription(@RequestBody PlExpressSubscriptionDto dto) {
		PlExpressSubscription req=new PlExpressSubscription();
		BeanUtils.copyProperties(dto,req);
		Page<PlExpressSubscription> pageParam = new Page<>(dto.getPageNum(),dto.getPageSize());
		plExpressSubscriptionService.selectByPage(pageParam, req);
		
		return EdiResponse.success().data("page",pageParam);
	}
	
	@ApiOperation(value = "授权订购关系列表", notes = "授权订购关系列表")
    @PostMapping("qryPlExpressSubscriptionById")
	public EdiResponse qryPlExpressSubscriptionById(@RequestBody PlExpressSubscriptionDto dto) {
		
		return EdiResponse.success().data("item",plExpressSubscriptionService.getById(dto.getId()));
	}

}
